const init = {
  studentAssignmentInfo: [{task: {}, topic: {}, assignment: {}}],
  studentsAssignmentInfo: [{
    task: {},
    topic: {},
    assignment: {},
    situation: {}
  }],
  assignmentStudents: []
}
export default (state = init, action) => {
  switch (action.type) {
    case 'STUDENT_ASSIGNMENTS':
      return Object.assign({}, state, {studentAssignmentInfo: action.assignmentInfo})
    case 'REFRESH_STUDENTS_ASSIGNMENTS':
      return Object.assign({}, state, {studentsAssignmentInfo: action.myStudentsAssignmentInfo})
    case 'REFRESH_ASSIGNMENT_STUDENTS':
      const oldAssignmentStudents = state.assignmentStudents.filter(item =>
        item.assignmentId !== action.assignmentStudents.assignmentId
      )
      return Object.assign({}, state, {assignmentStudents: [...oldAssignmentStudents, action.assignmentStudents]})
    default:
      return state
  }
}
